﻿using EWS;
using Microsoft.Exchange.WebServices.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UDataBaseWork;
using UEntity.LogEntity;

namespace ExchangeZhouqiMeetSYNC
{
    class Program
    {
        static void Main(string[] args)
        {
            string strSqlConn = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"]));//
            CBaseDB m_db = m_db = new CBaseDB(strSqlConn);
            if (!m_db.ExcuteBySql(" truncate table dbo.ZhouQiTemp ", out string strError))
            {
                ULogWork.CLogToTxtFile.RecordOperateLog(new EOperateLogEntity(" *********************清空失败, error:" + strError));
            }
            var service = ExChangeHelper.getExChangeHelper();
            var meetList = new List<Appointment>();
            //  ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
            var meetss = service.GetRoomLists();
            foreach (var meetRooms in meetss)
            {
                var meetRoom = service.GetRooms(meetRooms);
                foreach (var room in meetRoom)
                {
                    try
                    {
                        var list = ExChangeHelper.GetZhouqiEmailListByRoom(room.Address);

                    }
                    catch (Exception e)
                    {

                        continue;
                    }


                }

            }
            CParameters parameters = new CParameters();
            if (!m_db.ExcuteByTransaction(parameters, "spCannelZhouQiTempSync", out strError))
            {
                ULogWork.CLogToTxtFile.RecordOperateLog(new EOperateLogEntity(" *********************同步取消Exchange周期会议失败, error:" + strError));

            }

        }
    }
}
